package com.multiplayer.dao.impl;

import java.util.List;

import com.multiplayer.dao.ICommentsDao;
import com.multiplayer.entity.Announcement;
import com.multiplayer.entity.Comments;
import com.multiplayer.tools.DBTools;

/**
 * 
 * @author 温在鑫
 *@version   [版本号, 2020-05-08]
 *评论操作实现类
 *
 *@author 刘铁辉
 *@version   [版本号, 2020-05-10]
 *评论操作实现类方法实现
 */
public class CommentsDaoImpl implements ICommentsDao{

	@Override
	public boolean publishComments(Comments comments) {
		//发表评论
		String sql="insert into comments values(?,?,?,?,?);";
		int affectRows = DBTools.exUpdate(sql,comments.getCno(),comments.getUserid(),comments.getCcontent(),comments.getCstar(),comments.getCtime());
		return affectRows>0;
	} 

	@Override
	public boolean deleteCommentsById(String commentsId) {
		// 通过ID删除评论
		String sql="delete from comments where cno=?";
		int affectRows=DBTools.exUpdate(sql, commentsId);
		return affectRows>0;
	}

	@Override
	public List<Comments> queryCommentsByKeywords(String keywords) {
        //模糊查询评论
		String sql="select * from comments where userid like ? ";
		List<Comments> comList=(List<Comments>) DBTools.exQuery(sql, Comments.class, "%"+keywords+"%");
	    return comList; 
	}

}
